import React, { Component } from 'react'
import { StyleSheet, View, Text, Image, TouchableOpacity } from 'react-native'

import { connect } from 'react-redux'
import HeaderDefault from '../../components/header/HeaderDefault'
import { theme_app, theme_text } from '../../utils/appTheme'

import Toast from 'react-native-simple-toast'
import { green } from 'ansi-colors'
class Home extends Component {
  constructor(props) {
    super(props)
    this.state = {}
  }
  static navigationOptions = ({ navigation }) => ({
    gesturesEnabled: false,
    header: (
      <HeaderDefault
        leftBtnShow={false}
        title="首页"
        rihghtBtnOnPress={() => {
          navigation.navigate('Mine')
        }}
        rightImg={require('./src/person.png')}
        flag={true}
      />
    )
  })

  _renderItemCell(imgIcon, onPresss) {
    return (
      <View style={styles.itemCell}>
        <TouchableOpacity
          style={{
            flex: 1
          }}
          onPress={onPresss}
        >
          <Image
            resizeMode="contain"
            style={{ width: 0.5 * screenWidth - 10, height: 80 }}
            source={imgIcon}
          />
        </TouchableOpacity>
      </View>
    )
  }

  render() {
    return (
      <View style={styles.container}>
        <View style={{ height: 30 }} />
        <View style={styles.sectionCell}>
          {this._renderItemCell(require('./src/TIZhenLuRu.png'), () => {
            this.props.navigation.navigate('SignsEentry')
          })}
          {this._renderItemCell(require('./src/iPiLiangLuRu.png'), () => {
            this.props.navigation.navigate('SignsBatch')
          })}
        </View>

        <View style={styles.sectionCell}>
          {this._renderItemCell(require('./src/XunSHi.png'), () => {
            this.props.navigation.navigate('PatorlHome')
          })}

          {this._renderItemCell(require('./src/iHuLiPinGu.png'), () => {
            this.props.navigation.navigate('EveHome')
          })}
        </View>
        <View style={styles.sectionCell}>
          {this._renderItemCell(require('./src/iPeiYao.png'), () => {
            this.props.navigation.navigate('Dispense')
          })}
          {this._renderItemCell(require('./src/FuHeiShenHe.png'), () => {
            this.props.navigation.navigate('DispenseReview')
          })}
        </View>

        <View style={styles.sectionCell}>
          {this._renderItemCell(require('./src/YiZhuZhiXing.png'), () => {
            this.props.navigation.navigate('AdvicePerformHome')
          })}

          {this._renderItemCell(require('./src/paiyao.jpg'), () => {
            this.props.navigation.navigate('ArrangeDrugList')
          })}
        </View>
      </View>
    )
  }
}
const styles = StyleSheet.create({
  container: {
    width: screenWidth,
    height: screenHeight,
    backgroundColor: theme_app.bg_color
  },
  sectionCell: {
    width: screenWidth - 20,
    height: 100,
    flexDirection: 'row',
    marginTop: 10,
    marginLeft: 10,
    marginRight: 10
  },
  itemCell: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    padding: 5
  },
  tit_item: {
    fontSize: theme_text.large_font,
    fontWeight: 'bold',
    fontSize: 23,
    marginBottom: 10,
    marginTop: 10
  }
})

function select(store) {
  return {}
}

export default connect(select)(Home)
